package com.gomyb.admin.module.user.model;

import com.gomyb.common.base.BaseModel;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.util.Set;

/**
 * @author <a href="mailto:hellohesir@gmail.com">Mr_He</a>
 * 2019-04-01 16:59:05
 */
@Entity
@Table(name = "sys_role")
@Getter
@Setter
@DynamicUpdate
@DynamicInsert
public class SysRole extends BaseModel {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    private String name;  // 权限名称

    private Long parentId;  // 父级角色id

    private String description;  // 说明

    @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(name = "sys_role_permission", joinColumns = @JoinColumn(name = "role_id"), inverseJoinColumns = @JoinColumn(name = "permission_id"))
    private Set<SysPermission> permissionList;

}
